package com.jic.order.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.order.entity.OrderBaleDelivery;
import com.jic.order.mapper.OrderBaleDeliveryMapper;
import com.jic.order.service.OrderBaleDeliveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 物流信息表
 * @author :
 * @email :
 * @since : 2020-03-03 02:39:07
 * @version : v1.0.0
 */
@Service
public class OrderBaleDeliveryServiceImpl implements OrderBaleDeliveryService {

    @Autowired
    private OrderBaleDeliveryMapper orderBaleDeliveryMapper;

    @Override
    public long insert(OrderBaleDelivery orderBaleDelivery) {
        long flag = orderBaleDeliveryMapper.insert(orderBaleDelivery);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return orderBaleDeliveryMapper.delete(id);
    }

    @Override
    public long update(OrderBaleDelivery orderBaleDelivery) {
        return orderBaleDeliveryMapper.update(orderBaleDelivery);
    }

    @Override
    public OrderBaleDelivery queryByPrimaryKey(Long id){
        return orderBaleDeliveryMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderBaleDelivery> query(OrderBaleDelivery orderBaleDelivery){
        List<OrderBaleDelivery> query = orderBaleDeliveryMapper.query(orderBaleDelivery);
        return query;
    }

    @Override
    public PageResult<OrderBaleDelivery> queryPage(OrderBaleDelivery orderBaleDelivery, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<OrderBaleDelivery> list = orderBaleDeliveryMapper.queryPage(startIndex, pageQuery.getLimit(), orderBaleDelivery);
        long count = orderBaleDeliveryMapper.queryPageCount(orderBaleDelivery);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}
